package operation;

import student.Student;
import student.StudentArray;

import java.util.Scanner;

public class FindIndexOperation implements IOperation{
    @Override
    public void work(StudentArray stulist) {
        System.out.println("查找单个学生消息");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入查找学生的学号:->");
        int n = sc.nextInt();
        int sz = stulist.getUsedSize();
        for (int i = 0; i < sz; i++) {
            Student stu = stulist.getStudent(i);
            if(stu.getStudentId() == n){
                System.out.println("查找到了，该学生如下:");
                System.out.println(stu);
                return;
            }
        }
        System.out.println("未查找到该学生");
    }
}
